package com.example.nbshopping.setting;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.nbshopping.MainActivity;
import com.example.nbshopping.R;
import com.example.nbshopping.login.ChangePwdActivity;
import com.example.nbshopping.login.LoginRegActivity;
import com.example.nbshopping.login.PersonCenterActivity;
import com.example.nbshopping.login.UserBean;
import com.example.nbshopping.utils.SaveUserUtils;

public class SafetyActivity extends AppCompatActivity {
    TextView changePwdTv ,findPwdTv;
    ImageView backIv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_safety);
        initView();
        setListener();
    }

    private void setListener() {
        changePwdTv.setOnClickListener(clickListener);
        findPwdTv.setOnClickListener(clickListener);
        backIv.setOnClickListener(clickListener);
    }
    View.OnClickListener clickListener=new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (v.getId()){
                case R.id.safety_tv_changePwd:
                    islogin(0);
                    break;
                case R.id.safety_tv_findPwd:
                    break;
                case R.id.safety_iv_back:
                    finish();
                    break;
            }
        }
    };
    private void islogin(int flag) {
        UserBean.DataBean userInfo = SaveUserUtils.getUserInfo(this);
        if (userInfo==null) {
            Intent it1 = new Intent(this, LoginRegActivity.class);
            it1.putExtra("flag",flag);
            startActivity(it1);
        }else {
            Intent intent = new Intent(this, ChangePwdActivity.class);
            startActivity(intent);
        }
    }

    private void initView() {
        changePwdTv=findViewById(R.id.safety_tv_changePwd);
        findPwdTv=findViewById(R.id.safety_tv_findPwd);
        backIv=findViewById(R.id.safety_iv_back);
    }
}